package com.whatisjee.ssf.misc;

import java.io.Serializable;

public class ErrorMessage implements Serializable {
	private static final long serialVersionUID = -1282680771586781289L;
	
	public static enum Severity { INFO, WARN, ERROR, FATAL; }
	
	private final Severity severity;
	private final String oFor;
	private final String resKey;
	private final Object[] resParams;
	
	
	public static ErrorMessage createGlobalMessage(String resKey, Object... resParams) {
		return new ErrorMessage(Severity.ERROR, null, resKey, resParams);
	}
	
	public static ErrorMessage createGlobalMessage(Severity severity, String resKey, Object... resParams) {
		return new ErrorMessage(severity, null, resKey, resParams);
	}
	
	public static ErrorMessage createMessageFor(String oFor, String resKey, Object... resParams) {
		return new ErrorMessage(Severity.ERROR, oFor, resKey, resParams);
	}
	
	public static ErrorMessage createMessageFor(Severity severity, String oFor, String resKey, Object... resParams) {
		return new ErrorMessage(severity, oFor, resKey, resParams);
	}

	private ErrorMessage(Severity severity, String oFor, String resKey,
			Object... resParams) {
		this.severity = severity;
		this.oFor = oFor;
		this.resKey = resKey;
		this.resParams = resParams;
	}

	public Severity getSeverity() {
		return severity;
	}

	public String getFor() {		
		return oFor;
	}

	public String getResKey() {
		return resKey;
	}

	public Object[] getResParams() {
		return resParams;
	}
}
